<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
  <input type="text" placeholder="请输入数字" v-model="num">
  <input type="button" value="猜一猜" @click="f()">
  <h1>{{info}}</h1>
</div>

<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.min.js"></script>
<script>
  let x = parseInt(Math.random()*100)+1;
  let count = 1;
  let v = new Vue({
    el:"div",
    data:{
      info:x,
      num:""
    },
    methods:{
      f:function (){
        if(v.num>x){
          v.info="猜大了"
          count++
        }else if(v.num<x){
          v.info="猜小了"
          count++
        }else{
          v.info="恭喜你猜对了,你一共猜了"+count+"次"
        }
      }
    }



  })



  let num = Math.random()*100+1;



</script>
</body>
</html>